import java.util.Scanner;

public class F {
	private static boolean[] satisface = new boolean[20001];

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		rellenarSatisface();
		Scanner in = new Scanner(System.in);
		int caso = in.nextInt();
		while (caso != 0) {
			int n = caso;
			if (satisface[n]) {
				System.out.println("SI");
			} else {
				System.out.println("NO");
			}
			caso = in.nextInt();
		}
	}

	private static void rellenarSatisface() {
		satisface[0] = false;
		satisface[1] = true;
		satisface[2] = false;
		satisface[3] = true;
		satisface[4] = false;
		satisface[5] = false;
		for (int i = 6; i < 20001; i++) {
			if (satisface[i - 5] || (i % 3 == 0) && satisface[i / 3]) {
				satisface[i] = true;
			}
		}
	}

}
